import request from "@/utils/request";
enum API {
  //提交订单，获取订单号码接口
  SUBMITORDER_URL = "/order/orderInfo/auth/submitOrder/",
  //获取订单详情的数据
  GETORDERINFO_URL = "/order/orderInfo/auth/getOrderInfo/",
  //取消订单
  ORDERCANCEL_URL = "/order/orderInfo/auth/cancelOrder/",
  // 获取支付订单二维码接口
  QRCODE_URL = "/order/weixin/createNative/",
  //查询订单支付的结果
  PAYRESULT_URL = "/order/weixin/queryPayStatus/",
  //获取当前账号信息
  USERINFO_URL = "/user/auth/getUserInfo",
  //获取用户订单号的数据
  USERORDERINFO_URL = "/order/orderInfo/auth/",
  //获取全部就诊人
  ALLUSER_URL = "/user/patient/auth/findAll",
  //获取订单的状态
  ORDERSTATUS_URL = "/order/orderInfo/auth/getStatusList",
  //获取证件的类型的接口地址
  CERTIFICATIONTYPE_URL = "/cmn/dict/findByDictCode/",
  //获取城市的数据
  CITY_URL = "/cmn/dict/findByParentId/",
  //新增就诊人
  ADDUSER_URL = "/user/patient/auth/save",
  //更新
  UPDATAUSER_URL = "/user/patient/auth/update",
  //删除
  DELETEUSER_URL = "/user/patient/auth/remove/"
}
//提交订单
export const reqSubmitOrder = (
  hoscode: string,
  scheduleId: string,
  patientId: number
) =>
  request.post(API.SUBMITORDER_URL + `${hoscode}/${scheduleId}/${patientId}`);
//获取订单详情的数据
export const reqOrderInfo = (id: string) =>
  request.get(API.GETORDERINFO_URL + id);
//取消订单
export const reqOrderCancel = (id: string) =>
  request.get(API.ORDERCANCEL_URL + id);
// 获取支付订单二维码接口
export const reqQrcode = (orderId: string) =>
  request.get(API.QRCODE_URL + orderId);
//查询订单支付的结果
export const reqPayResult = (orderId: string) =>
  request.get(API.PAYRESULT_URL + orderId);
//获取当前账号信息
export const reqUserInfo = () => request.get(API.USERINFO_URL);
//获取用户订单号的数据
export const reqUserOrderInfo = (
  page: number,
  limit: number,
  patientId: string,
  orderStatus: string
) =>
  request.get(
    API.USERORDERINFO_URL +
      `${page}/${limit}?patientId=${patientId}&orderStatus=${orderStatus}`
  );
//获取全部就诊人
export const reqAllUser = () => request.get(API.ALLUSER_URL);
//获取订单的状态
export const reqOrderStatus = () => request.get(API.ORDERSTATUS_URL);
//获取证件类型的方法
export const reqCertationType = (CertificatesType = "CertificatesType") =>
  request.get(API.CERTIFICATIONTYPE_URL + CertificatesType);
//获取城市的数据
export const reqCity = (parentId: string) =>
  request.get(API.CITY_URL + parentId);
//新增就诊人
export const reqAddOrUpDataUser = (data: any) => {
  if (data.id) {
    return request.put(API.UPDATAUSER_URL, data);
  } else {
    return request.post(API.ADDUSER_URL, data);
  }
};
//删除
export const reqDeleteUser = (id: number) =>
  request.delete(API.DELETEUSER_URL + id);
